// 其中是试卷管理部分所需的函数
import request from '@/utils/request'

// 获取试卷列表
export const examStoreList = ()=>request({
    url:'question/paper/getRelatedPaper',
    method:'get',
});

// 获取部分试卷列表
export const getAllNoPassedPaper = (status)=>request({
    url:'question/paper/getAllNoPassedPaper',
    method:'get',
    params:{status}
});

// 添加试卷或者修改试卷
export const examAddOrUpdateStore = (paper,mes)=>{
    //通过id判断是添加还是修改
    if(paper.id){
        return request({
            url:'question/paper/updatePaperInfo',
            method:'post',
            data:paper,
            params:{message:mes+"修改试卷信息"}
        });
    }else{
        return request({
            url:'question/paper/createNewPaper',
            method:'post',
            data:paper,
            params:{message:mes+"新建一张试卷"}
        });
    }
};

// 复制试卷
export const pastePaper = (paper,paperId)=>request({
    url:`question/paper/pastePaper`,
    method:'post',
    data:paper,
    params:{paperId}
});

//删除试卷
//deletePersonalQuestionStore/{personalQuestionStoreId}
export const examDeleteStore = (paperId)=>request({
    url:`question/paper/deleteOnePaper`,
    method:'delete',
    params:{paperId:paperId}
});


//根据名称查看老师全部信息
export const getTeacherByName = (name)=>request({
    url:`question/paper/getTeacherByName`,
    method:'get',
    params:{name}
});

//邀请某老师一起管理试卷
export const inviteOneTeacherForPaper = (teacherId,paperId,permission)=>request({
    url:`question/paper/inviteOneTeacherForPaper`,
    method:'post',
    params:{teacherId,paperId,permission}
});

//更改某个老师对该试卷的权限
export const updatePaperPermissionForTeacher = (teacherId,paperId,permission)=>request({
    url:`question/paper/updatePaperPermissionForTeacher`,
    method:'post',
    params:{teacherId,paperId,permission}
});

// 移除老师的权限
export const deleteTeacherFromPaper = (teacherId,paperId)=>request({
    url:`question/paper/deleteTeacherFromPaper`,
    method:'post',
    params:{teacherId,paperId}
});
// 以下是对于单张试卷老师的操作

// 查询一张试卷的所有题目以及操作日志
export const getPaperInventory = (paperId)=>request({
    url:`question/paper/getPaperInventory`,
    method:'post',
    params:{paperId }
});
// 查询一次智能组卷，相关限制条件的题目数量
export const getCountIntelligent = (param)=>request({
    url:`question/paper/getCountIntelligent`,
    method:'post',
    data:param,
});

// 智能组卷
export const intelligentPaper = (param,paperId,message)=>request({
    url:`question/paper/intelligentPaper`,
    method:'post',
    data:param,
    params:{
        paperId,message
    }
});

// 老师自定义添加试题
export const addQuestionToPaper = (paperQuestion,message)=>request({
    url:`question/paper/addCustomizeQuestionToPaper`,
    method:'post',
    data:paperQuestion,
    
    params:{
        message
    }
});

// 老师往试卷中添加自己题库的题目
export const addPersonalQuestionToPaper = (paperId,personalQuestionId,location,message, score)=>request({
    url:`question/paper/addPersonalQuestionToPaper`,
    method:'post',
    params:{
        paperId,personalQuestionId,location,message, score
    }
});

// 老师在试卷中添加总题库的题目
export const addWholeQuestionToPaper = (paperId,questionId,location,message,score)=>request({
    url:`question/paper/addQuestionToPaper`,
    method:'post',
    params:{
        paperId,questionId,location,message, score
    }
});

// 删除试卷的某一道题目
export const deleteOnePaperQuestion = (paperQuestionId, message, paperId)=>request({
    url:`question/paper/deleteOnePaperQuestion`,
    method:'delete',
    params:{
        paperQuestionId, message, paperId
    }
});

// 更新试卷的某一到题目
export const updatePaperQuestion = (paperQuestion)=>request({
    url:`question/paper/updatePaperQuestion`,
    method:'post',
    data:paperQuestion,
});

// 将试卷提交审核
export const SubmitForApproval = (paperId)=>request({
    url:`question/paper/submitPaper`,
    method:'post',
    params:{paperId},
});

// 更改题目的位置，和更新题目是一个接口
export const updateLocation = (id1, id2, paperId,message)=>request({
    url:`question/paper/exchangeLocationById`,
    method:'post',
    params:{
        id1, id2, paperId,message
    }
});

// 确定所有题目位置
export const confirmAllPaperQuestionLocation = (param, paperId,message)=>request({
    url:`question/paper/confirmAllPaperQuestionLocation`,
    method:'post',
    data:param,
    params:{
        paperId,message
    }
});

// 批量或单个添加总题库试题
export const addPaperQuestionFromTotal = (param,paperId,message)=>request({
    url:`question/paper/addPaperQuestionFromTotal`,
    method:'post',
    data:param,
    params:{
        paperId,message
    }
});

// 批量化或单个添加个人题库试题
export const addPaperQuestionFromPersonal = (param,paperId,message)=>request({
    url:`question/paper/addPaperQuestionFromPersonal`,
    method:'post',
    data:param,
    params:{
        paperId,message
    }
});



// 发布考试
// 后面分别是监考老师们，和阅卷老师们

export const releasePaperToExam = (params)=>request({
    url:`/exam/exam/releasePaperToExam`,
    method:'post',
    data:params,
});
// 查看所有考试
export const getExam = (exam,current,limit,status)=>request({
    url:`/exam/exam/getExam`,
    method:'post',
    data:exam,
    params:{current,limit,status}

});
// 删除考试
export const deleteExam = (examId)=>request({
    url:`/exam/exam/deleteExam`,
    method:'delete',
    params:{
        examId
    }
});

// 添加监考老师
export const addProctor = (examId,teacherId)=>request({
    url:`/exam/exam/addProctor`,
    method:'put',
    params:{
        examId,teacherId
    }
});

// 添加阅卷老师
export const addMarking = (examId,teacherId)=>request({
    url:`/exam/exam/addMarking`,
    method:'put',
    params:{
        examId,teacherId
    }
});

// 移除监考老师
export const removeProctor = (examId,teacherId)=>request({
    url:`/exam/exam/removeProctor`,
    method:'delete',
    params:{
        examId,teacherId
    }
});

// 移除阅卷老师
export const removeMarking = (examId,teacherId)=>request({
    url:`/exam/exam/removeMarking`,
    method:'delete',
    params:{
        examId,teacherId
    }
});

// 修改越卷信息
export const updateExam = (exam)=>request({
    url:`/exam/exam/updateExam`,
    method:'post',
    data:exam
});

// 查询某个试卷的监考老师
export const getProctorTeacher = (examId)=>request({
    url:`/exam/exam/getProctorTeacher`,
    method:'get',
    params:{examId}
});

// 查询某个考试的阅卷老师
export const getMarkingTeacher = (examId)=>request({
    url:`/exam/exam/getMarkingTeacher`,
    method:'get',
    params:{examId}
});

// 查询某考试中学生成绩
export const getAllStudentForExam = (examStudentVo)=>request({
    url:`/exam/statistical/getAllStudentForExam`,
    method:'post',
    data:examStudentVo
});

// 查询某场考试的最高分，最低分，平均分
export const getMaxMinAvgScoreOfExam = (examId)=>request({
    url:`/exam/statistical/getMaxMinAvgScoreOfExam`,
    method:'get',
    params:{examId}
});